iT邦幫忙

2025 iThome 鐵人賽

DAY 24
0
自我挑戰組

從零開始學習Unity引擎系列 第 24

unity學習day24--製作遊戲(3)

  • 分享至 

  • xImage
  •  

複製Coin預製體,並且改名為“RedCoin”,接著建立一個紅色材質命名為“M_Red”,然後掛到“RedCoin”上。
https://ithelp.ithome.com.tw/upload/images/20250926/20178373Zti4VSXH7A.png

在“Scripts”下面建立腳本命名“CheckpointCoin”,然後在腳本裡面寫設置重生點,吃到紅色金幣加分的同時還能設置重生點,最後把腳本掛到“RedCoin”上。
https://ithelp.ithome.com.tw/upload/images/20250926/20178373sC94Dt5vFG.png

在“Scripts”建立腳本“PlayerRespawn”,並寫入重生的程式碼。
https://ithelp.ithome.com.tw/upload/images/20250926/201783734IS6vZOVqf.png

然後把這個“PlayerRespawn”掛到Player上,Y軸設置就暫定-20,後面根據需要再調整。
https://ithelp.ithome.com.tw/upload/images/20250926/20178373wParLK7aM1.png

吃到紅色金幣就可以控制人物走到平台的邊緣往下跳,跳下去之後會回到出生點。
https://ithelp.ithome.com.tw/upload/images/20250926/201783738oP3767C9u.png
https://ithelp.ithome.com.tw/upload/images/20250926/20178373Bzpi2qK6LL.png

在“專案”建立一個材質“M_Road”當做路的材質隨便選一個自己喜歡的材質加上去,接下來建立一個空物件“A_Road”,然後把位置設為(0,0.9,13)。然後右鍵“A_Road”建立一個立方體命名“Tile_01”,也就是“A_Road”的子物件,然後把“Tile_01”的相對位置設為(0,0,0),縮放設為(2,0.3,6),然後在“A_Road”下面建立子物件“Tile_02”,“Tile_03”,它們的相對位置分別為(0,0,6),(0,0,12),每次Z軸增加6,依次類推一共做8個。
https://ithelp.ithome.com.tw/upload/images/20250926/20178373MeGZXFSHbP.png


上一篇
unity學習day23—製作遊戲(2)
系列文
從零開始學習Unity引擎24
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言